package com.Arsanesia.TempleRush.Controllers.Listeners;

import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;


public class SettingButtonListener extends ClickListener{
	private final float LEFT_MARGIN = 10;
	private final float BOTTOM_MARGIN = 20;
	ImageButton soundbutton, vibrationbutton;
	private boolean toggle;
	private float buttonHeight;
	public SettingButtonListener(ImageButton sound, ImageButton vibration, float _buttonheight){
		super();
		soundbutton = sound;
		vibrationbutton = vibration;
		toggle = false;
		this.buttonHeight = _buttonheight;
	}
	public void clicked(InputEvent event, float x, float y){
		super.clicked(event, x, y);
		toggle =!toggle;
		if(toggle){
			//set buttons to be visible
			vibrationbutton.addAction(Actions.alpha(1));
			soundbutton.addAction(Actions.alpha(1));
			//move buttons
			vibrationbutton.addAction(Actions.moveTo(LEFT_MARGIN,buttonHeight+BOTTOM_MARGIN, 0.5f));
			soundbutton.addAction(Actions.moveTo(LEFT_MARGIN,vibrationbutton.getY()+vibrationbutton.getHeight()+soundbutton.getHeight()+BOTTOM_MARGIN+25, 0.5f));

		}else{
			soundbutton.addAction(Actions.parallel(Actions.moveTo(LEFT_MARGIN,0, 0.1f), Actions.alpha(0, 0.3f)));
			vibrationbutton.addAction(Actions.parallel(Actions.moveTo(LEFT_MARGIN,0, 0.1f), Actions.alpha(0, 0.3f)));
		}
	}
}
